package com.example.springjpa.rabbitmq;


import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: zsw
 * @time: 2021/7/31 9:39
 */
@Component
public class ConfirmCallbackService implements RabbitTemplate.ConfirmCallback {
    /*** @param correlationData 相关配置信息 * @param ack exchange交换机 是否成功收到了消息。true 成功，false代表失败 * @param cause 失败原因 */
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            //接收成功
            System.out.println("成功发送到交换机<===>");
        } else { //接收失败
            System.out.println("失败原因:===>" + cause);
        }
    }
}